<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.17"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>libschc: compressor.h File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">libschc
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.17 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">compressor.h File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="bit__operations_8h_source.html">bit_operations.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="schc_8h_source.html">schc.h</a>&quot;</code><br />
</div>
<p><a href="compressor_8h_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:a15002a02e9cae01e5629cb2d474fe482"><td class="memItemLeft" align="right" valign="top">int8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="compressor_8h.html#a15002a02e9cae01e5629cb2d474fe482">set_rule_id</a> (struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> *schc_rule, uint8_t *data)</td></tr>
<tr class="separator:a15002a02e9cae01e5629cb2d474fe482"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a4fd03f3acd56b4bf55fc4c8e48567ab7"><td class="memItemLeft" align="right" valign="top">uint8_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="compressor_8h.html#a4fd03f3acd56b4bf55fc4c8e48567ab7">schc_compressor_init</a> (uint8_t src[16])</td></tr>
<tr class="memdesc:a4fd03f3acd56b4bf55fc4c8e48567ab7"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes the SCHC compressor.  <a href="compressor_8h.html#a4fd03f3acd56b4bf55fc4c8e48567ab7">More...</a><br /></td></tr>
<tr class="separator:a4fd03f3acd56b4bf55fc4c8e48567ab7"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0b9e16aa71f4074dec7245991fdebcdb"><td class="memItemLeft" align="right" valign="top">int16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="compressor_8h.html#a0b9e16aa71f4074dec7245991fdebcdb">schc_compress</a> (uint8_t *data, uint16_t total_length, <a class="el" href="structschc__bitarray__t.html">schc_bitarray_t</a> *buf, uint32_t device_id, <a class="el" href="schc_8h.html#a99f26e6ee9fcd62f75203b5402df8098">direction</a> dir, struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> **schc_rule)</td></tr>
<tr class="memdesc:a0b9e16aa71f4074dec7245991fdebcdb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Compresses a CoAP/UDP/IP packet.  <a href="compressor_8h.html#a0b9e16aa71f4074dec7245991fdebcdb">More...</a><br /></td></tr>
<tr class="separator:a0b9e16aa71f4074dec7245991fdebcdb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aaf76c0525a94eecb1f694ba09b435c49"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="compressor_8h.html#aaf76c0525a94eecb1f694ba09b435c49">get_schc_rule_by_reliability_mode</a> (struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> *schc_rule, <a class="el" href="schc_8h.html#a00b61f9b90ab7065eb6a978141d7fd34">reliability_mode</a> mode, uint32_t device_id)</td></tr>
<tr class="separator:aaf76c0525a94eecb1f694ba09b435c49"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aad3e564426f2baa62e653ebdb5635e2e"><td class="memItemLeft" align="right" valign="top">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="compressor_8h.html#aad3e564426f2baa62e653ebdb5635e2e">get_schc_rule_by_rule_id</a> (uint8_t *rule_id, uint32_t device_id)</td></tr>
<tr class="separator:aad3e564426f2baa62e653ebdb5635e2e"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8af6027989d3e39cdcc37f16ff38d7ff"><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="compressor_8h.html#a8af6027989d3e39cdcc37f16ff38d7ff">schc_decompress</a> (<a class="el" href="structschc__bitarray__t.html">schc_bitarray_t</a> *bit_arr, uint8_t *buf, uint32_t device_id, uint16_t total_length, <a class="el" href="schc_8h.html#a99f26e6ee9fcd62f75203b5402df8098">direction</a> dir)</td></tr>
<tr class="memdesc:a8af6027989d3e39cdcc37f16ff38d7ff"><td class="mdescLeft">&#160;</td><td class="mdescRight">Construct the header from the layered set of rules.  <a href="compressor_8h.html#a8af6027989d3e39cdcc37f16ff38d7ff">More...</a><br /></td></tr>
<tr class="separator:a8af6027989d3e39cdcc37f16ff38d7ff"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="aaf76c0525a94eecb1f694ba09b435c49"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaf76c0525a94eecb1f694ba09b435c49">&#9670;&nbsp;</a></span>get_schc_rule_by_reliability_mode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a>* get_schc_rule_by_reliability_mode </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> *&#160;</td>
          <td class="paramname"><em>schc_rule</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="schc_8h.html#a00b61f9b90ab7065eb6a978141d7fd34">reliability_mode</a>&#160;</td>
          <td class="paramname"><em>mode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>device_id</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="aad3e564426f2baa62e653ebdb5635e2e"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aad3e564426f2baa62e653ebdb5635e2e">&#9670;&nbsp;</a></span>get_schc_rule_by_rule_id()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a>* get_schc_rule_by_rule_id </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>rule_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>device_id</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
<a id="a0b9e16aa71f4074dec7245991fdebcdb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0b9e16aa71f4074dec7245991fdebcdb">&#9670;&nbsp;</a></span>schc_compress()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int16_t schc_compress </td>
          <td>(</td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>total_length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structschc__bitarray__t.html">schc_bitarray_t</a> *&#160;</td>
          <td class="paramname"><em>dst</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>device_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="schc_8h.html#a99f26e6ee9fcd62f75203b5402df8098">direction</a>&#160;</td>
          <td class="paramname"><em>dir</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> **&#160;</td>
          <td class="paramname"><em>schc_rule</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Compresses a CoAP/UDP/IP packet. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>pointer to the original packet </td></tr>
    <tr><td class="paramname">total_length</td><td>the length of the packet </td></tr>
    <tr><td class="paramname">dst</td><td>pointer to the bit array object, where the compressed packet will be stored. Can later be passed to fragmenter </td></tr>
    <tr><td class="paramname">device_id</td><td>the device id to find a rule for </td></tr>
    <tr><td class="paramname">direction</td><td>the direction of the flow UP: LPWAN to IPv6 or DOWN: IPv6 to LPWAN </td></tr>
    <tr><td class="paramname">device_type</td><td>the device type: NETWORK_GATEWAY or DEVICE </td></tr>
    <tr><td class="paramname">schc_rule</td><td>a pointer to a schc rule struct to return the rule that was found</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>length the length of the compressed packet -1 on a memory overflow</dd></dl>
<dl class="section note"><dt>Note</dt><dd>the compressor will only look for rules configured with the NOT_FRAGMENTED reliability mode </dd></dl>

</div>
</div>
<a id="a4fd03f3acd56b4bf55fc4c8e48567ab7"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a4fd03f3acd56b4bf55fc4c8e48567ab7">&#9670;&nbsp;</a></span>schc_compressor_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint8_t schc_compressor_init </td>
          <td>(</td>
          <td class="paramtype">uint8_t&#160;</td>
          <td class="paramname"><em>src</em>[16]</td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initializes the SCHC compressor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">node_ip</td><td>a pointer to the source it's ip address</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>error error codes on error </dd></dl>

</div>
</div>
<a id="a8af6027989d3e39cdcc37f16ff38d7ff"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8af6027989d3e39cdcc37f16ff38d7ff">&#9670;&nbsp;</a></span>schc_decompress()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t schc_decompress </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="structschc__bitarray__t.html">schc_bitarray_t</a> *&#160;</td>
          <td class="paramname"><em>bit_arr</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>buf</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>device_id</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>total_length</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="schc_8h.html#a99f26e6ee9fcd62f75203b5402df8098">direction</a>&#160;</td>
          <td class="paramname"><em>dir</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Construct the header from the layered set of rules. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">data</td><td>pointer to the received data </td></tr>
    <tr><td class="paramname">buf</td><td>pointer where to save the decompressed packet </td></tr>
    <tr><td class="paramname">device_id</td><td>the device its id </td></tr>
    <tr><td class="paramname">total_length</td><td>the total length of the received data </td></tr>
    <tr><td class="paramname">direction</td><td>the direction of the flow (UP: LPWAN to IPv6, DOWN: IPv6 to LPWAN)</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>length length of the newly constructed packet 0 the rule was not found </dd></dl>

</div>
</div>
<a id="a15002a02e9cae01e5629cb2d474fe482"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a15002a02e9cae01e5629cb2d474fe482">&#9670;&nbsp;</a></span>set_rule_id()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int8_t set_rule_id </td>
          <td>(</td>
          <td class="paramtype">struct <a class="el" href="structschc__rule__t.html">schc_rule_t</a> *&#160;</td>
          <td class="paramname"><em>schc_rule</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint8_t *&#160;</td>
          <td class="paramname"><em>data</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

</div>
</div>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.17
</small></address>
</body>
</html>
